<?php
class MatchingBonusPage extends MemberPage {
    private static $default_parent = 'CommissionPage';

    private static $db = array();

    private static $has_one = array();

}

class MatchingBonusPage_Controller extends MemberPage_Controller {

    /**
     * An array of actions that can be accessed via a request. Each array element
     * should be an action name, and the
     * permissions or conditions required to allow the user to access it.
     *
     * <code>
     * array (
     *     'action', // anyone can access this action
     *     'action' => true, // same as above
     *     'action' => 'ADMIN', // you must have ADMIN permissions to access this
     * action
     *     'action' => '->checkAction' // you can only access this action if
     * $this->checkAction() returns true
     * );
     * </code>
     *
     * @var array
     */
    private static $allowed_actions = array(
        'Form'
    );

    public function init() {
        parent::init();
    }

    function Form() {
        $fields = FieldList::create(
            DateRangeField::create('Batch__Date', _t('MatchingBonusPage.DATE', 'Date'))
        );

        $field_list = array(
            'Batch.Date' => _t('MatchingBonusPage.DATE', 'Date'),
            'Description' => _t('MatchingBonusPage.BONUS_DESCRIPTION', 'Description'),
            'AmountText' => array('title' => _t('MatchingBonusPage.AMOUNT', 'Amount ({currency})', '', array('currency' => SiteCurrencyConfig::current_site_currency())), 'classes' => 'text-right'),
            'ForwardBalance' => array('title' => _t('MatchingBonusPage.BALANCE', 'Balance ({currency})', '', array('currency' => SiteCurrencyConfig::current_site_currency())), 'classes' => 'text-right')
        );
        $casting_list = array(
            'Batch.Date' => 'Date->Nice',
            'ForwardBalance' => 'Double->Nice'
        );

        return DataListSearchForm::create($this, 'Form', 'MatchingBonus', array('MemberID' => $this->CurrentMember()->ID), $fields)->setDataFieldList($field_list)->setFieldCasting($casting_list);
    }
}
